package cn.jbolt.ai.app.controller;

import cn.jbolt.ai.app.service.AiAppMessageService;
import cn.jbolt.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@ResponseBody
@RequestMapping("/aiAppMessage")
@Tag(name = "会话消息controller")
public class AiAppMessageController {

    @Autowired
    private AiAppMessageService aiAppMessageService;

    @Operation(summary = "根据会话主键ID,分页获取聊天记录")
    @GetMapping("/getListByPage")
    public Result listByPage(Integer pageSize, String sessionId,
                                    @RequestParam(required = false) Long startId) {

        return aiAppMessageService.listByPage(sessionId, startId, pageSize);
    }


    @Operation(summary = "根据会话主键ID,清空当前会话下的聊天记录")
    @GetMapping("/deleteBySessionId/{sessionId}")
    public Result delete(@PathVariable Long sessionId) {
        return aiAppMessageService.delete(sessionId);
    }

    @Operation(summary = "根据message主键ID,删除关联的两条聊天记录")
    @GetMapping("/delMsgById/{msgId}")
    public Result delMsgById(@PathVariable Long msgId) {
        return aiAppMessageService.delMsgById(msgId);
    }

}
